package spec.asumuliu.unit5.zuoye;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import static java.lang.Math.PI;

public class IncludeClassTest {

    public static void main(String[] args) {
        //math 类测试
        double d = Math.sin(PI / 5);
        System.out.println(d);
        System.out.println(Math.sqrt(1000));
        System.out.println(Math.pow(2, 10));
        System.out.println(Math.floor(100.9));
        System.out.println(Math.ceil(100.1));
        System.out.println(Math.round(100.4));
        System.out.println(Math.round(100.5));

        //StringBuffer
        StringBuffer sb = new StringBuffer("abcdefgHIJK");
        System.out.println(sb.length());    //14
        System.out.println(sb);
        sb.insert(1, 'M');
        System.out.println(sb);
        sb.insert(2, 'N');
        System.out.println(sb);
        sb.delete(10, 11);
        System.out.println(sb);
        sb.replace(13, 15, "NM");
        System.out.println(sb);

//Calendar类测试
        GregorianCalendar gre=new GregorianCalendar();
        String now=gre.get(Calendar.YEAR)+"年"+gre.get(Calendar.MONTH)+"月"+gre.get(Calendar.DATE)+"日"+gre.get(Calendar.HOUR_OF_DAY)+":"+gre.get(Calendar.MINUTE)+":"+gre.get(Calendar.SECOND);
        System.out.println(now);

        Calendar cal=Calendar.getInstance();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 EEEE");
        cal.set(Calendar.DAY_OF_MONTH,1);
        int n=1;
        while (n<=23){
            if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.MONDAY){
                Date date=cal.getTime();
            System.out.println(sdf.format(date));
            n++;
            cal.add(Calendar.MONTH,1);
            }
        }
    }
}